﻿@model IEnumerable<GameStore2.Models.Game>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>
@if (User.Identity.Name == "ahmedbilal") { 
<p>
    @Html.ActionLink("Create New", "Create")
</p>
}
<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Company.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Description)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.GameUrl)
        </th>
        
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Company.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Description)
        </td>
        <td>
            <a href="@Html.DisplayFor(modelItem => item.GameUrl)">@item.Name</a>
        </td>
        <td>
        @Html.ActionLink("Details", "Details", new { id = item.GameId })
        @if (User.Identity.Name == "ahmedbilal")
        {       @:|
                @Html.ActionLink("Edit", "Edit", new { id = item.GameId }) <text>|</text>
                @Html.ActionLink("Delete", "Delete", new { id = item.GameId })
        }
        </td>
    </tr>
}

</table>
